package com.wing.utils;

import com.wing.common.exception.BusinessException;
import com.wing.common.utils.JsonResult;

public class HttpUtil {

    public static void JsonResultHandle(JsonResult jsonResult) {
        if (jsonResult == null || jsonResult.getCode() != JsonResult.Code.SUCCESS.getCode()) {
            throw new BusinessException("返回数据为空或错误: " + (jsonResult != null ? jsonResult.getMsg() : "未知错误"));
        }
    }
    
    public static Object JsonResultDataHandle(JsonResult jsonResult) {
        if (jsonResult == null || jsonResult.getCode() != JsonResult.Code.SUCCESS.getCode() || jsonResult.getData() == null) {
            throw new BusinessException("返回数据为空或错误: " + (jsonResult != null ? jsonResult.getMsg() : "未知错误"));
        }
        return jsonResult.getData();
    }
}
